package com.liuhengjia.aiknowledgebase.config;

import com.lark.oapi.Client;
import com.lark.oapi.core.enums.BaseUrlEnum;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

/**
 * FeiShu 客户端配置类
 */
@Slf4j
@Configuration
@RequiredArgsConstructor
public class FeiShuClientConfig {
    private final FeiShuConfig feiShuConfig;

    /**
     * FeiShu 客户端 Bean 对象
     *
     * @return Client
     */
    @Bean
    public Client getClient() {
        /*log.error(feiShuConfig.getAppId());
        log.error(feiShuConfig.getAppSecret());
        log.error(feiShuConfig.getRootFolder());*/
        return Client.newBuilder(feiShuConfig.getAppId(), feiShuConfig.getAppSecret())
                .marketplaceApp()
                .openBaseUrl(BaseUrlEnum.FeiShu)
                .requestTimeout(3, TimeUnit.SECONDS)
                .logReqAtDebug(true)
                .build();
    }
}
